﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Roberts.Samples.Web.Models;
using Roberts.MvcExtensions;
using System.Diagnostics;
using System.Reflection;

namespace Roberts.Samples.Web.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        private static string ProductVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion;

        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        public ActionResult SiteInfo()
        {
            var model = new SampleSiteInfoModel();
            TimeZone localZone = TimeZone.CurrentTimeZone;
            DateTime now = DateTime.Now;
            model.ServerTimeZoneName = localZone.IsDaylightSavingTime(now) ? localZone.DaylightName : localZone.StandardName;
            model.Version = ProductVersion;

            return new JsonpResult<SampleSiteInfoModel>(model, true, true);
        }
    }
}
